---@class BattleTeamDarkStreetPanel : UIComponentBase
local BattleTeamDarkStreetPanel = Class(nil,UIComponentInterface)

local StageLan = {"DarkLaneTipes_9","DarkLaneTipes_10","DarkLaneTipes_11","DarkLaneTipes_40","DarkLaneTipes_41"}
local StageDesLan = {"DarkLaneTipes_12","DarkLaneTipes_13","DarkLaneTipes_14","DarkLaneTipes_42","DarkLaneTipes_43"}
function BattleTeamDarkStreetPanel:OnCreate(curObj,nextObj,limitText,limitText2,ctrlNext)
    self.curObj = curObj
    self.nextObj = nextObj
    self.limitText = limitText
    self.limitText2 = limitText2
    self.ctrlNext = ctrlNext
end
function BattleTeamDarkStreetPanel:OnDestroy()
    self.dataList = nil
    self.curObj = nil
    self.nextObj = nil
    self.limitText = nil
    self.limitText2 = nil
    self.ctrlNext = nil
end
function BattleTeamDarkStreetPanel:Refresh()
    self.dataList = decodeJsonStrToTabel(dataTable.getGlobalString(359))
    local mapId  = logicMgr.MapManager.getMapId()
    local count = #self.dataList
    self.curIndex = 1
    for k,v in pairs(self.dataList) do
        if mapId >= v[1] and mapId<=v[2] then
            self.curIndex = k
            break
        end
    end
    self.nextIndex = math.min(self.curIndex + 1,count)
    self.limitText.text = string.format(getLanguage("DarkLaneTipes_15"),DarkStreetMgr.resCountInWeek,self.dataList[self.curIndex][4])
    local limit = dataTable.getGlobalInt(548)
    self.limitText2.text = string.format(getLanguage("DarkStreetRewardLimit2"),DarkStreetMgr.resCompensationInWeek,limit)
    self:InitCur(self.curObj)
    if self.curIndex < self.nextIndex then
        self.ctrlNext.selectedIndex = 1
        self:InitNext(self.nextObj)
    else
        self.ctrlNext.selectedIndex = 0
    end
end
function BattleTeamDarkStreetPanel:InitCur(obj)
    local Text_Stage = obj:GetChild("Text_Stage")
    local Text_StageTips = obj:GetChild("Text_StageTips")
    local Text_StageRewardCur = obj:GetChild("Text_StageReward01")
    --local Text_StageRewardRate = obj:GetChild("Text_StageReward02")
    local goldRewardCur = obj:GetChild("Text_StageReward03")
    local limitIcon = obj:GetChild("Img_Rewardicon01")
    local data = self.dataList[self.curIndex]
    Text_Stage.text = getLanguage(StageLan[self.curIndex])
    Text_StageTips.text = getLanguage(StageDesLan[self.curIndex])
    Text_StageRewardCur.text = "x"..data[3]
    limitIcon.url = logicMgr.ItemManager.GetItemIconPath(logicMgr.DarkStreetMgr.resItemModelId)
    goldRewardCur.text = "x"..dataTable.getGlobalInt(547)
    --Text_StageRewardRate.text = "x1"
end
function BattleTeamDarkStreetPanel:InitNext(obj)
    local Text_Stage = obj:GetChild("Text_Stage")
    local Text_StageTips = obj:GetChild("Text_StageTips")
    local Text_StageRewardCur = obj:GetChild("Text_StageReward01")
    --local Text_StageRewardRate = obj:GetChild("Text_StageReward02")
    local goldRewardCur = obj:GetChild("Text_StageReward03")
    local Text_UnlockTips = obj:GetChild("Text_UnlockTips")
    local limitIcon = obj:GetChild("Img_Rewardicon01")
    local data = self.dataList[self.nextIndex]
    Text_Stage.text = getLanguage(StageLan[self.nextIndex])
    Text_StageTips.text = getLanguage(StageDesLan[self.nextIndex])
    Text_StageRewardCur.text = "x"..data[3]
    goldRewardCur.text = "x"..dataTable.getGlobalInt(547)
    limitIcon.url = logicMgr.ItemManager.GetItemIconPath(logicMgr.DarkStreetMgr.resItemModelId)
    --Text_StageRewardRate.text = "x1"
    local cfg = dataTable.getDataTableByStringId("t_stage",data[1])
    if not cfg then
        logError("找不到t_stage "..data[1])
        return
    end
    local str = cfg.f_ChapterId .. "-" .. cfg.f_StageNum;
    Text_UnlockTips.text = string.format(getLanguage("FunctionTipsStage"), str)
end
return BattleTeamDarkStreetPanel